package com.bizfx.component.views
{
	import mx.collections.ArrayCollection;
	import mx.collections.IList;
	import mx.utils.ObjectProxy;

	[Bindable]
	public class NavigatorItemBase extends ObjectProxy
	{
		private var _key:String;
		
		public function get key(): String {
			return _key;  
		}
		
		public function set key(value: String):void {
			_key = value;
		}
		
		private var _text:String;
		
		public function get text(): String
		{
			return _text;  
		}
		
		public function set text(value: String):void
		{
			_text = value;  
		} 
		
		private var _value:String;
		
		public function get value(): String
		{
			return _value;  
		}
		
		public function set value(value: String):void
		{
			_value = value;  
		} 
		
		private var _link:String;
		
		public function get link(): String
		{
			return _link;  
		}
		
		public function set link(value: String):void
		{
			_link = value;  
		} 
		
		private var _isLeaf:Boolean;
		
		public function get isLeaf():Boolean
		{
			return _isLeaf;  
		}
		
		public function set isLeaf(value: Boolean):void
		{
			_isLeaf = value;  
		}
		
		private var _hasLoadedChildren:Boolean = false;
		
		public function get hasLoadedChildren(): Boolean
		{
			return _hasLoadedChildren;  
		}
		
		public function set hasLoadedChildren(value:Boolean):void
		{
			_hasLoadedChildren = value;  
		} 
		
		private var _parentKey:String;
		
		public function get parentKey(): String
		{
			return _parentKey;  
		}
		
		public function set parentKey(value: String):void
		{
			_parentKey = value;  
		}
		
//		private var _children:IList;
//
//		public function get children():IList
//		{
//			if (this._children == null) {
//				this._children = new ArrayCollection();
//			}
//			return _children;
//		}
//
//		public function set children(value:IList):void
//		{
//			_children = value;
//		}

		public function NavigatorItemBase()
		{
		}
		
		public static function fromObject(obj:Object):NavigatorItemBase
		{
			if (obj == null) return null;
			
			var result:NavigatorItemBase = new NavigatorItemBase();
			if (obj.hasOwnProperty("key"))
			{
				result.key = obj.key;
			}
			
			if (obj.hasOwnProperty("text"))
			{
				result.text = obj.text;
			}
			
			if (obj.hasOwnProperty("value"))
			{
				result.value = obj.value;
			}
			
			if (obj.hasOwnProperty("link"))
			{
				result.link = obj.link;
			}
			
			if (obj.hasOwnProperty("isLeaf"))
			{
				result.isLeaf = obj.isLeaf;
			}
			
			if (obj.hasOwnProperty("hasLoadedChildren"))
			{
				result.hasLoadedChildren = obj.hasLoadedChildren;
			}
			
			if (obj.hasOwnProperty("parentKey"))
			{
				result.parentKey = obj.parentKey;
			}
			return result;
		}
	}
}